import javax.swing.ImageIcon;
import javax.swing.JLabel;

public class MapSquare extends JLabel
{
    private static final long serialVersionUID = 1L;
    
    String defaultImage;    
    GameObject gameObject;
    JLabel foreGround;
    
    public MapSquare()
    {
    	//set up the Icon and the foreGround to both be grass
        defaultImage="src/images/Map/grass.png";
        gameObject=null;
        this.setIcon(new ImageIcon(defaultImage));
        foreGround=new JLabel(new ImageIcon(defaultImage));
    }
    
    public MapSquare(GameObject game)
    {
    	//set the Icon to the GameObject image, and default back
        defaultImage="src/images/Map/grass.png";
        this.setIcon(new ImageIcon(defaultImage));
        foreGround=new JLabel(new ImageIcon(defaultImage));
        gameObject = game;
        update();
    }

    public void update()
    {   
    	//if a GameObject has been added, update the main Icon
    //to reflect the object
        if(gameObject!=null){
            this.setIcon(new ImageIcon(gameObject.filePath));
        } else{
            this.setIcon(new ImageIcon(defaultImage));
        }
        this.setOpaque(false);
    }
    
}
